package edu.upb.acs.jobsmaps.voice;

import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dani on 6/28/2014.
 */
public class DropDownComplete {
	private static final String TAG = DropDownComplete.class.getName();

	public static Integer setDropDownValue(Spinner spinner, ArrayList<String> textMatchList) {
		ArrayAdapter myAdap = (ArrayAdapter) spinner.getAdapter(); //cast to an ArrayAdapter
		int nrElements = myAdap.getCount();

		List<String> valuesSpinner = new ArrayList<>();
		for (int i = 0; i < nrElements; i++) {
			valuesSpinner.add(spinner.getItemAtPosition(i).toString());
		}

		for (int i = 0; i < valuesSpinner.size(); i++) {
			for (int j = 0; j < textMatchList.size(); j++) {
				Log.d(TAG, "textMatchList: " + textMatchList.get(j));
				if (valuesSpinner.get(i).equalsIgnoreCase(textMatchList.get(j))) {
					return i;
				}
			}
		}
		return null;
	}
}
